package merge;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * 每次读取一个数字放到自定义的bean作为key
 */
public class MergeMapper extends Mapper<LongWritable, Text, MergeBean, NullWritable> {
    MergeBean mergeBean = new MergeBean();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String text = value.toString();
        mergeBean.setNumber(Integer.parseInt(text));
        context.write(mergeBean,NullWritable.get());
    }
}
